package org.fu.crowd.utils;

public class Common<T> {
    public static final String SUCCESS = "SUCCESS";
    public static final String FAILED = "FAILED";
    //
    private String result;
    private String message;
    private T data;

    public Common() {
    }

    /**
     * 请求成功
     * @param <Type>
     * @return
     */
    public static <Type> Common<Type> successWithoutData(){
        return new Common<>(SUCCESS,null,null);
    }
    public static <Type> Common<Type> successWithoutData(Type type){
        return new Common<>(SUCCESS,null,type);
    }

    /**
     * 请求失败
     * @param
     * @return
     */
    public static Common failed(String message){
        return new Common(FAILED,message,null);
    }


    public Common(String result, String message, T data) {
        this.result = result;
        this.message = message;
        this.data = data;
    }

    @Override
    public String toString() {
        return "Common{" +
                "result='" + result + '\'' +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
